package com.cloudcc.mobile.adapter;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.content.Context;
import android.graphics.Color;
import android.widget.ImageView;
import android.widget.TextView;

import com.cloudcc.cloudframe.adapter.CommonAdapter;
import com.cloudcc.cloudframe.adapter.ViewHolder;
import com.cloudcc.mobile.R;
import com.cloudcc.mobile.entity.approval.ApprovalModel;

public class ExaminationApprovalAdapter extends CommonAdapter<ApprovalModel>{
	private SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
	private SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd");
	private Date date = new Date();
	public ExaminationApprovalAdapter(Context mContext) {
		super(mContext);
		
	}

	@Override
	public void convert(ViewHolder holder, ApprovalModel t) {
		int i = holder.getPostion();
		ImageView item_img = holder.getView(R.id.approval_item_img);
		TextView item_line = holder.getView(R.id.approval_item_line);
		if(i==0){
			item_img.setImageResource(R.drawable.ico_red_arrow);
			item_line.setBackgroundColor(Color.RED);
		}else{
			item_img.setImageResource(R.drawable.ico_gray_arrow);
			item_line.setBackgroundColor(Color.GRAY);
		}
		holder.setText(R.id.approval_approval_name, t.getApproval_name());
		holder.setText(R.id.approval_item_time, formatter.format(date));
		holder.setText(R.id.approval_item_date, formatter1.format(date));
		holder.setText(R.id.approval_item_commit, t.getType());
		holder.setText(R.id.approval_item_allocationedman, t.getAllocationed_man());
		holder.setText(R.id.approval_item_approvalman, t.getApproval_man());
		holder.setText(R.id.approval_item_note, t.getNote());
		holder.setText(R.id.approval_item_wholetype, t.getWhole_type());
	}

	@Override
	public int getLayoutId() {
		// TODO Auto-generated method stub
		return R.layout.examination_approval_item;
	}
}
